﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Data.Linq.Mapping;

using log4net;

namespace DataDesign.MPP.Domain
{
    [Table(Name=GeneralDepartmentColumns.TABLE_NAME)]
    public class GeneralDepartment:BaseDomain<GeneralDepartment>,ICommonFunctions<GeneralDepartment>
    {
        readonly static ILog logger = LogManager.GetLogger(typeof(GeneralDepartment));
        [Column(Name = GeneralDepartmentColumns.DEPARTMENT_NAME)]
        public string DepartmentName
		{
			get;
            set;
        }
        [Column(Name = GeneralDepartmentColumns.DEPARTMENT_ID, AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
        public int DepartmentID { get; set; }
        
        #region ICommonFunctions
        public GeneralDepartment GetByPrimaryKey()
        {
            Table<GeneralDepartment> table=GetTable();

            GeneralDepartment item = table.Single(t=>t.DepartmentID.Equals(this.DepartmentID));

            return item;

        }
        #endregion

        public static Dictionary<int, string> GetDictionary()
        {
            return GeneralDepartment.GetAll().ToDictionary(row => row.DepartmentID, row => row.DepartmentName);
        }

    }
}
